﻿// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, DdddOcrLib v1.0.2!\n");

//string imagePath = $"{ Directory.GetCurrentDirectory() }\\File\\a.png";
//string imageName = AppDomain.CurrentDomain.BaseDirectory;

var imageDic = new Dictionary<string, string> 
{
    { "a1", "uwv6"},
    { "a2", "vwo7" },
    { "b1", "?+9=10" },
    { "b2", "HCUK" },
    { "b3", "..." },
    { "q1", "佛学大托哈者幸" },
    { "q2", "执地仁把" },
    { "q3", "但火数化" },
    { "q4", "炸颤篱媚" },
    { "q5", "友极余青" }
};


//string imagePath = $@"C:\Users\sws-dev-server\Desktop\dapr-demo\dapr-demo\Test.ConsoleApp\File\l4.jpg";
//byte[] imageByte = File.ReadAllBytes(imagePath);
//string codeStr = DdddOcrLib.Ocr.Classification(imageByte);
//Console.WriteLine(codeStr);

Console.ReadLine();

double count = 0;

foreach (var item in imageDic)
{
    string imagePath = $@"C:\Users\sws-dev-server\Desktop\dapr-demo\dapr-demo\Test.ConsoleApp\File\{item.Key}.jpg";
    byte[] imageByte = File.ReadAllBytes(imagePath);
    string codeStr = DdddOcrLib.Ocr.Classification(imageByte);

    string isOk = string.Empty;
    if (codeStr == item.Value)
    {
        isOk = "ok";
        count += 1;
    }
    else
    {
        isOk = "no";
    }

    Console.WriteLine($"{item.Key} ==> 识别字符：{codeStr} ||| 原有字符：{item.Value} ==> 是否正确：{ isOk }");
}

Console.WriteLine($"识别准确率：{ (count / imageDic.Count) * 100 } %");

Console.ReadLine();
